//
// Created by lenovo on 2024/8/11.
//

#ifndef TREELIB_TREE_MUTITREE_TEMPLATETREE_H
#define TREELIB_TREE_MUTITREE_TEMPLATETREE_H
#include "./__multitree__.h"
#include "./iTree.h"

namespace TREE{
    // 定义概念，检查类型是否为 Node<T> 的子类
    template <typename T, typename U>
    concept _node_impl = std::is_base_of_v<Node<U>, T> && not std::is_abstract_v<T> ;


    template <typename _Node>
        requires _node_impl<_Node, typename _Node::value_type>
    class TemplateTree : public iTree<typename _Node::value_type> {
    protected:
        _Node* _root ;
    public:
        using value_type = _Node::value_type ;
        using node_type = _Node ;
        static _Node* to_node (value_type data) {
            return new node_type (data) ;
        }

        TemplateTree(_Node* root) : _root(root) {}

        virtual Node<value_type >* root() {
            return _root ;
        }
    };
}
#endif //TREELIB_TREE_MUTITREE_TEMPLATETREE_H
